<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>车联数据模拟</title>
</head>
<link rel="stylesheet" href="./static/bootstrap-3.4.1/css/bootstrap.css"/>
<link rel="stylesheet" href="./static/layer/mobile/need/layer.css">
<script src="./static/vehicle/js/jquery.min.js"></script>
<script src="./static/layer/layer.js"></script>
<script src="./static/bootstrap-3.4.1/js/bootstrap.js"></script>
<script src="./static/vehicle/js/muyu.js"></script>
<script src="./static/vehicle/js/md5.js"></script>
<body>
<style>
    .divCss{
        margin: 5px 5px;
        border-radius: 5px;
    }
    .divBorderHeight{
        border: solid 1px #0081a7 ;
    }
    .vinDiv::-webkit-scrollbar {/*滚动条整体样式*/
        width:3px;    /*高宽分别对应横竖滚动条的尺寸*/
        height:1px;
    }
    .vinDiv::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
        border-radius:10px;
        -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
        background:#009dcc;
    }
    .vinDiv::-webkit-scrollbar-track {/*滚动条里面轨道*/
        -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
        border-radius:10px;
        background:#EDEDED;
    }
    .vinDiv span{
        float: left;
        margin: 5px 15px 5px 0;
        font-size: 15px;
        cursor:pointer;
    }
    .vinDiv{
        height: 820px;
        float: left;
        overflow: hidden;
        overflow-y: auto;
    }
    .col-md-2 {
        width: 16%;
    }
    .message{
        border-bottom: #0673b3 2px solid;
        border-right: #0673b3 2px solid;
        width: 33.33%;
    }
</style>
<div style="margin-right: 10px; margin-left: 10px;">
    <div class="col-md-12 divCss divBorderHeight">
        <div class="col-md-5 divCss divBorderHeight">
            <div class="form-inline">
                <div class="form-group">
                    <label for="host">地址</label>
                    <input type="text" class="form-control" name="" id="host" placeholder="IP地址" value="127.0.0.1">
                </div>
                <div class="form-group">
                    <label for="port">端口</label>
                    <input type="text" class="form-control" name="" id="port" placeholder="端口" value="8000">
                </div>
                <button type="button" class="btn btn-sm btn-default" onclick="connect()">连接</button>
                <button type="button" class="btn btn-sm btn-danger" onclick="disConnect()">关闭</button>
                <span id="connect" class="label label-success" style="display: none">已连接</span>
                <span id="disconnect" class="label label-danger">已断开</span>
            </div>
        </div>
        <div class="col-md-1 divCss divBorderHeight" style="padding: 2px">
            <div class="col-md-4">
                <button type="button" class="btn btn-sm btn-default" onclick="startNettySendMsg()">上报</button>
            </div>
            <div class="col-md-4">
                <button type="button" class="btn btn-sm btn-default" onclick="stopNettyStopMsg()">停止</button>
            </div>
        </div>
        <div class="col-md-2 divCss divBorderHeight" style="padding: 2px">
            <div class="col-md-6">
                <button type="button" class="btn btn-sm btn-default" onclick="startImitateData()">开始模拟</button>
            </div>
            <div class="col-md-6">
                <button type="button" class="btn btn-sm btn-default" onclick="stopImitateData()">结束模拟</button>
            </div>
        </div>

        <div class="col-md-2 divCss divBorderHeight" style="padding: 7px 0">
            <span class="col-md-7">当累计上报数据量：</span>
            <span class="label label-info" id="sendSum">12312</span>
            <span id="send" class="label label-success" style="display: none">上报中</span>
            <span id="disSend" class="label label-danger">未上报</span>
        </div>
    </div>
    <form id="vehicleForm">
    <div class="col-md-12 divCss divBorderHeight" style="height: 875px;">
        <h4>上报数据模拟</h4>
        <hr style="margin-top: 10px; margin-bottom: 10px; border-top: 2px solid #080808;">
        <div class="col-md-12">
            <div class="vinDiv" style="border-right: #0673b3 2px solid; width: 15%;">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label for="vin">VIN</label>
                        <input type="text" value="vin123" class="form-control" name="vin" id="vin" placeholder="VIN" maxlength="17">
                    </div>
                    <div class="form-group">
                        <label for="drivingRoute">选择路线</label>
                        <select onchange="selectLocus()" type="text" class="form-control" name="drivingRoute" id="drivingRoute">
                            <option value="-">请选择行驶路线</option>
                            <option value="path1">模拟路径1</option>
                            <option value="path2">模拟路径2</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="speed">车速</label>
                        <div class="input-group">
                            <input type="text" min="50" max="80" reserved="2" class="form-control" name="speed" id="speed" placeholder="车速">
                            <div class="input-group-addon">KM/H</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mileage">里程</label>

                        <div class="input-group">
                            <input type="text" min="1" max="8" reserved="3" class="form-control" name="mileage" id="mileage" placeholder="里程">
                            <div class="input-group-addon">KM</div>
                        </div>
                    </div>  
                    <div class="form-group">
                        <label for="voltage">总电压</label>

                        <div class="input-group">
                            <input type="text" min="110" max="750" reserved="2" class="form-control" name="voltage" id="voltage" placeholder="总电压">
                            <div class="input-group-addon">V</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="current">总电流</label>
                        <div class="input-group">
                            <input  type="text" min="3" max="50" reserved="2" class="form-control" name="current" id="current" placeholder="总电流">
                            <div class="input-group-addon">A</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="resistance">绝缘电阻</label>
                        <div class="input-group">
                            <input  type="text" min="0" max="300000" reserved="2" class="form-control" name="resistance" id="resistance" placeholder="绝缘电阻">
                            <div class="input-group-addon">Ω</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="gear">档位</label>
                        <select class="form-control" name="gear" id="gear">
                            <option value="P" selected>驻车</option>
                            <option value="R">倒车</option>
                            <option value="N">空挡</option>
                            <option value="D">正常模式</option>
                            <option value="S">运动模式</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="accelerationPedal">加速踏板行程值</label>
                        <input  type="text" min="0" max="10" reserved="0" class="form-control" name="accelerationPedal" id="accelerationPedal" placeholder="加速踏板行程值">
                    </div>
                    <div class="form-group">
                        <label for="brakePedal">制动踏板行程值</label>
                        <input  type="text" min="0" max="10" reserved="0" class="form-control" name="brakePedal" id="brakePedal" placeholder="制动踏板行程值">
                    </div>
                    <div class="form-group">
                        <label for="fuelConsumptionRate">燃料消耗率</label>
                        <div class="input-group">
                            <input  type="text" min="0" max="20" reserved="2" class="form-control" name="fuelConsumptionRate" id="fuelConsumptionRate" placeholder="燃料消耗率">
                            <div class="input-group-addon">L/百公里</div>
                        </div>
                    </div>

                </div>
            </div>

            <div class="vinDiv" style="border-right: #0673b3 2px solid; width: 15%;">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label for="motorControllerTemperature">电机控制器温度</label>
                        <input  type="text" min="0" max="100" reserved="2" class="form-control" name="motorControllerTemperature" id="motorControllerTemperature" placeholder="电机控制器温度">
                    </div>
                    <div class="form-group">
                        <label for="motorSpeed">电机转速</label>
                        <input  type="text" min="0" max="10000" reserved="0" class="form-control" name="motorSpeed" id="motorSpeed" placeholder="电机转速">
                    </div>
                    <div class="form-group">
                        <label for="motorTorque">电机转矩</label>
                        <input  type="text" min="0" max="1000" reserved="0" class="form-control" name="motorTorque" id="motorTorque" placeholder="电机转矩">
                    </div>
                    <div class="form-group">
                        <label for="motorTemperature">电机温度</label>
                        <input  type="text" min="0" max="150" reserved="2" class="form-control" name="motorTemperature" id="motorTemperature" placeholder="电机温度">
                    </div>
                    <div class="form-group">
                        <label for="motorVoltage">电机电压</label>
                        <input  type="text" min="13" max="15" reserved="2" class="form-control" name="motorVoltage" id="motorVoltage" placeholder="电机电压">
                    </div>
                    <div class="form-group">
                        <label for="motorCurrent">电机电流</label>
                        <input  type="text" min="0" max="15000" reserved="2" class="form-control" name="motorCurrent" id="motorCurrent" placeholder="电机电流">
                    </div>
                </div>
            </div>
            <div class="vinDiv" style="border-right: #0673b3 2px solid; width: 15%;">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label for="remainingBattery">动力电池剩余电量SOC</label>

                        <div class="input-group">
                            <input  type="text" min="0" max="100" reserved="2" class="form-control" name="remainingBattery" id="remainingBattery" placeholder="动力电池剩余电量SOC">
                            <div class="input-group-addon">%</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="maximumFeedbackPower">当前状态允许的最大反馈功率</label>
                        <input  type="text" min="0" max="100" reserved="2" class="form-control" name="maximumFeedbackPower" id="maximumFeedbackPower" placeholder="当前状态允许的最大反馈功率">
                    </div>
                    <div class="form-group">
                        <label for="maximumDischargePower">当前状态允许最大放电功率</label>
                        <input  type="text" min="0" max="100" reserved="2" class="form-control" name="maximumDischargePower" id="maximumDischargePower" placeholder="当前状态允许最大放电功率">
                    </div>
                    <div class="form-group">
                        <label for="selfCheckCounter">BMS自检计数器</label>
                        <input  type="text" min="0" max="15" reserved="0" class="form-control" name="selfCheckCounter" id="selfCheckCounter" placeholder="BMS自检计数器">
                    </div>
                    <div class="form-group">
                        <label for="totalBatteryCurrent">动力电池充放电电流</label>
                        <div class="input-group">
                            <input  type="text" min="0" max="15" reserved="2" class="form-control" name="totalBatteryCurrent" id="totalBatteryCurrent" placeholder="动力电池充放电电流">
                            <div class="input-group-addon">A</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="totalBatteryVoltage">动力电池负载端总电压V3</label>
                        <div class="input-group">
                            <input  type="text" min="220" max="750" reserved="2" class="form-control" name="totalBatteryVoltage" id="totalBatteryVoltage" placeholder="动力电池负载端总电压V3">
                            <div class="input-group-addon">V</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="singleBatteryMaxVoltage">单次最大电压</label>
                        <div class="input-group">
                            <input  type="text" min="3" max="5" reserved="2" class="form-control" name="singleBatteryMaxVoltage" id="singleBatteryMaxVoltage" placeholder="单次最大电压">
                            <div class="input-group-addon">V</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="singleBatteryMinVoltage">单体电池最低电压</label>
                        <div class="input-group">
                            <input  type="text" min="3" max="5" reserved="2" class="form-control" name="singleBatteryMinVoltage" id="singleBatteryMinVoltage" placeholder="单体电池最低电压">
                            <div class="input-group-addon">V</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="singleBatteryMaxTemperature">单体电池最高温度</label>
                        <div class="input-group">
                            <input  type="text" min="0" max="100" reserved="2" class="form-control" name="singleBatteryMaxTemperature" id="singleBatteryMaxTemperature" placeholder="单体电池最高温度">
                            <div class="input-group-addon">℃</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="singleBatteryMinTemperature">单体电池最低温度</label>
                        <div class="input-group">
                            <input  type="text" min="0" max="100" reserved="2" class="form-control" name="singleBatteryMinTemperature" id="singleBatteryMinTemperature" placeholder="单体电池最低温度">
                            <div class="input-group-addon">℃</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="availableBatteryCapacity">动力电池可用容量</label>
                        <div class="input-group">
                            <input  type="text" min="0" max="100" reserved="2" class="form-control" name="availableBatteryCapacity" id="availableBatteryCapacity" placeholder="动力电池可用容量">
                            <div class="input-group-addon">%</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="vinDiv" style="border-right: #0673b3 2px solid; width: 55%;">
                <div class="vinDiv message" style="height: 495px;">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label style="cursor: default;">车辆状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="vehicleStatus" id="vehicleStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="vehicleStatus" id="vehicleStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">充电状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="chargingStatus" id="chargingStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="chargingStatus" id="chargingStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">运行状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="operatingStatus" id="operatingStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="operatingStatus" id="operatingStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">SOC：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="socStatus" id="socStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="socStatus" id="socStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">可充电储能装置工作状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="chargingEnergyStorageStatus" id="chargingEnergyStorageStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="chargingEnergyStorageStatus" id="chargingEnergyStorageStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">驱动电机状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="driveMotorStatus" id="driveMotorStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="driveMotorStatus" id="driveMotorStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">定位是否有效：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="positionStatus" id="positionStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="positionStatus" id="positionStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="vinDiv message" style="height: 495px;">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label style="cursor: default;">EAS(汽车防盗系统)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="easStatus" id="easStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="easStatus" id="easStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">PTC(电动加热器)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="ptcStatus" id="ptcStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="ptcStatus" id="ptcStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">EPS(电动助力系统)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="epsStatus" id="epsStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="epsStatus" id="epsStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">ABS(防抱死)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="absStatus" id="absStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="absStatus" id="absStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">MCU(电机/逆变器)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="mcuStatus" id="mcuStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="mcuStatus" id="mcuStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="vinDiv message" style="height: 495px;">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label style="cursor: default;">动力电池加热状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="heatingStatus" id="heatingStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="heatingStatus" id="heatingStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">动力电池当前状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="batteryStatus" id="batteryStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="batteryStatus" id="batteryStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">动力电池保温状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="batteryInsulationStatus" id="batteryInsulationStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="batteryInsulationStatus" id="batteryInsulationStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">DCDC(电力交换系统)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="dcdcStatus" id="dcdcStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="dcdcStatus" id="dcdcStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label style="cursor: default;">CHG(充电机)状态：</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="chgStatus" id="chgStatusNormal" value="1" checked>
                                    正常
                                </label>
                                <label>
                                    <input type="radio" name="chgStatus" id="chgStatusAbnormal" value="0">
                                    异常
                                </label>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="vinDiv" id="vehicleMsgLog" style="height :325px ;width: 100%; padding: 0 15px;">

                </div>
            </div>
        </div>
    </div>
    </form>
</div>
</body>
<script>
    var nettyLogTime = null;
    var nettyMsgTime = null;

    var vehicleImitateData = null;
    var uid = '';
    var path = {
        path1: ["116.664053,39.531791","116.66438,39.53199","116.665067,39.532478","116.66556,39.532879","116.66607,39.533219","116.666268,39.53343","116.666789,39.533794","116.668,39.5347","116.669202,39.535577","116.669964,39.536214","116.670248,39.536293","116.670656,39.536289","116.67087,39.536541","116.670799,39.536898","116.670568,39.537064","116.67038,39.537432","116.670327,39.538086","116.670235,39.538996","116.670152,39.539968","116.670152,39.539968","116.670169,39.540365","116.670093,39.541209","116.670045,39.541697","116.669949,39.542748","116.669911,39.542963","116.669884,39.543542","116.669857,39.54377","116.669841,39.544039","116.669811,39.54439","116.669789,39.544621","116.669741,39.545126","116.669714,39.545593","116.669698,39.545804","116.669656,39.546451","116.66964,39.546662","116.669527,39.547166","116.669626,39.547133","116.670103,39.547179","116.670484,39.547216","116.670994,39.547257","116.671809,39.547315","116.67263,39.547386","116.673089,39.547415","116.673373,39.547498","116.674065,39.547547","116.675176,39.547643","116.675961,39.547703","116.676583,39.547757","116.677393,39.547828","116.678005,39.547881","116.67859,39.547914","116.679089,39.547931","116.679228,39.54791","116.679829,39.547964","116.680703,39.548039","116.681186,39.54808","116.681637,39.548113","116.682216,39.548163","116.682935,39.548221","116.683402,39.548262","116.683627,39.548324","116.684132,39.548379","116.685092,39.548454","116.686444,39.548582","116.686809,39.548611","116.687739,39.548685","116.688726,39.548785","116.689536,39.548843","116.689927,39.548863","116.690206,39.548888","116.690732,39.548934","116.691455,39.549","116.692249,39.54907","116.692651,39.549091","116.693086,39.549128","116.693665,39.549194","116.69389,39.549219","116.694598,39.549273","116.695784,39.549397","116.696245,39.549376","116.69698,39.549446","116.697189,39.549459","116.697619,39.549521","116.697983,39.549525","116.69874,39.549579","116.698911,39.549653","116.699426,39.54967","116.699673,39.549711","116.700462,39.549786","116.700923,39.54981","116.701277,39.549852","116.701695,39.549889","116.702157,39.549914","116.702543,39.549963","116.702881,39.549988","116.703423,39.550021","116.704013,39.550083","116.704624,39.550112","116.704603,39.549992","116.704614,39.549798","116.704651,39.549463","116.704704,39.549051","116.704768,39.548761","116.704795,39.548298","116.704913,39.547417","116.704972,39.546953","116.705095,39.545857","116.705229,39.544898","116.705235,39.544658","116.70531,39.544062","116.705422,39.543483","116.70546,39.542966","116.705503,39.542486","116.705658,39.541373","116.705707,39.540992","116.70576,39.54057","116.705793,39.540302","116.705857,39.53983","116.705905,39.539334","116.705948,39.538978","116.70598,39.538667","116.70605,39.538183","116.706098,39.537828","116.706136,39.537546","116.706195,39.537071","116.706291,39.536272","116.706383,39.535763","116.706426,39.535308","116.706458,39.53506","116.706533,39.534506","116.706565,39.53422","116.706672,39.533355","116.70671,39.533029","116.706747,39.532664","116.706817,39.532234","116.706876,39.531696","116.706958,39.531083","116.707011,39.530512","116.707049,39.530239","116.707103,39.529871","116.707156,39.529321","116.707215,39.528957","116.707247,39.528717","116.70729,39.528427","116.707344,39.528022","116.707382,39.527604","116.707419,39.527413","116.70743,39.52724","116.707451,39.527066","116.707489,39.526784","116.707542,39.52635","116.707607,39.525804","116.707628,39.525688","116.707671,39.525245","116.707666,39.525307","116.707671,39.525278","116.707741,39.524786","116.707781,39.524421","116.707797,39.524214","116.70784,39.523887","116.707867,39.523734","116.707902,39.523415","116.707961,39.52308","116.707993,39.522645","116.708047,39.522261","116.708084,39.521954","116.708138,39.521553","116.708159,39.521387","116.708202,39.521023","116.708245,39.520725","116.708288,39.520407","116.708326,39.520022","116.708422,39.5195","116.708449,39.519045","116.708508,39.518607","116.708556,39.518259","116.708615,39.517589","116.708663,39.517328","116.708706,39.517017","116.708749,39.516682","116.708819,39.516322","116.708835,39.516086","116.708905,39.515569","116.708937,39.51547","116.708567,39.515474","116.708175,39.515482","116.707703,39.515486","116.707414,39.515482","116.706797,39.515495","116.706303,39.515482","116.7053,39.515507","116.704613,39.515515","116.704369,39.515242","116.704095,39.514969","116.703849,39.514708","116.703811,39.5147","116.703559,39.514431","116.703232,39.514083","116.702904,39.513727","116.702593,39.513425","116.702298,39.513119","116.70203,39.512834","116.701628,39.512519","116.70129,39.512349","116.701102,39.512411","116.700635,39.512457","116.700201,39.512486","116.699965,39.512511","116.699428,39.512565","116.699101,39.512602","116.698709,39.512631","116.698034,39.512709","116.6968,39.512807","116.695663,39.51294","116.694193,39.513047","116.693013,39.513188","116.692734,39.513221","116.691833,39.513263","116.690739,39.513329","116.690277,39.513279","116.689773,39.513329","116.688732,39.513296","116.687828,39.51328","116.687308,39.513255","116.686991,39.513242","116.686149,39.513205","116.685554,39.51318","116.685103,39.513193","116.684626,39.51316","116.684164,39.513156","116.683306,39.513118","116.682748,39.513081","116.681793,39.513065","116.6813,39.513048","116.68049,39.513015","116.679074,39.512957","116.678478,39.512903","116.67799,39.512878","116.677352,39.512858","116.676831,39.512816","116.676204,39.512783","116.67556,39.51275","116.675088,39.512738","116.674772,39.512696","116.67446,39.512684","116.674017,39.512672","116.673818,39.512663","116.67326,39.512618","116.673013,39.512601","116.672434,39.512585","116.672032,39.512556","116.671291,39.51251","116.670685,39.512473","116.67031,39.512473","116.66994,39.512436","116.669398,39.512432","116.668877,39.512403","116.66855,39.512353","116.668207,39.51234","116.667746,39.512316","116.667086,39.512274","116.666592,39.512225","116.666378,39.512249","116.666313,39.512502","116.666286,39.512738","116.666244,39.512982","116.666227,39.513156","116.666217,39.513379","116.666125,39.513942","116.666072,39.514381","116.666034,39.514579","116.666024,39.514815","116.665965,39.5152","116.665889,39.51573","116.665841,39.51609","116.665761,39.51664","116.665739,39.516897","116.665682,39.517227","116.665671,39.517318","116.66566,39.517463","116.665607,39.517802","116.665574,39.518063","116.665526,39.51851","116.665478,39.5188","116.665435,39.519015","116.665419,39.519201","116.665378,39.519652","116.665335,39.519917","116.665314,39.520128","116.66526,39.5205","116.665223,39.520707","116.665115,39.521585","116.665083,39.521775","116.665035,39.522081","116.665013,39.522251","116.664992,39.522458","116.664951,39.52279","116.664892,39.523175","116.664844,39.52358","116.664737,39.524362","116.664673,39.524714","116.664646,39.52502","116.66464,39.525181","116.664576,39.525508","116.664538,39.525802","116.664479,39.52622","116.664463,39.52639","116.664426,39.526688","116.664378,39.527058","116.664319,39.527455","116.664319,39.527455","116.664248,39.527948","116.664189,39.528312","116.664136,39.528788","116.664114,39.529036","116.664071,39.529276","116.664023,39.529619","116.66398,39.529934","116.663913,39.530326","116.663865,39.530674","116.663817,39.531071","116.663817,39.531071","116.663994,39.531687","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778","116.664069,39.531778"],
        path2: ["116.655091,39.52091","116.65558,39.520922","116.655987,39.520951","116.656373,39.520997","116.657178,39.521063","116.657629,39.521121","116.658181,39.521146","116.658478,39.521163","116.658977,39.521209","116.659444,39.521254","116.66005,39.521292","116.660699,39.521345","116.660908,39.521391","116.661107,39.521378","116.661327,39.521407","116.662099,39.521467","116.662887,39.521521","116.663318,39.521562","116.664193,39.521637","116.664836,39.52167","116.665062,39.521732","116.665357,39.521765","116.66585,39.521798","116.666397,39.521835","116.667014,39.521889","116.667513,39.521918","116.668173,39.521964","116.668479,39.521997","116.669047,39.522042","116.669439,39.522075","116.6699,39.522121","116.67019,39.522129","116.670606,39.522187","116.671382,39.522247","116.671876,39.522267","116.672117,39.522226","116.672595,39.522271","116.673019,39.522321","116.673373,39.522334","116.673662,39.522363","116.674054,39.5224","116.674421,39.52242","116.67507,39.522474","116.675569,39.522524","116.675934,39.522557","116.67661,39.522615","116.67706,39.522644","116.677827,39.522706","116.678466,39.522764","116.67889,39.522793","116.679887,39.522867","116.680172,39.522904","116.680263,39.52295","116.680553,39.522962","116.680891,39.523008","116.681159,39.523016","116.681604,39.523053","116.682135,39.523107","116.682419,39.523107","116.682983,39.523095","116.683385,39.523012","116.6836,39.522967","116.6839,39.522892","116.684066,39.522847","116.68434,39.522797","116.684522,39.522751","116.684833,39.522681","116.685225,39.522615","116.685499,39.522532","116.685965,39.522499","116.686421,39.522557","116.686888,39.522727","116.687162,39.522875","116.687162,39.522875","116.688342,39.523513","116.689028,39.523856","116.689259,39.523984","116.690176,39.52458","116.690546,39.524874","116.691206,39.525453","116.691582,39.525755","116.691684,39.525863","116.691898,39.525747","116.692113,39.525909","116.692129,39.526128","116.692424,39.526149","116.692783,39.526194","116.693207,39.526231","116.693745,39.52626","116.694619,39.526343","116.695027,39.52638","116.695397,39.526397","116.695671,39.526409","116.695848,39.526434","116.696406,39.526471","116.697022,39.526537","116.698138,39.526641","116.698476,39.526657","116.698728,39.526678","116.699319,39.526741","116.700076,39.526799","116.700526,39.526828","116.700918,39.526861","116.701401,39.526907","116.702071,39.526956","116.702908,39.527031","116.703359,39.527068","116.704072,39.527109","116.704571,39.527155","116.705118,39.527192","116.705698,39.52725","116.706196,39.527287","116.706899,39.527345","116.707339,39.527378","116.707607,39.527416","116.708085,39.527457","116.708594,39.527503","116.708916,39.527536","116.709125,39.527565","116.709528,39.527606","116.70986,39.527639","116.710059,39.527635","116.710322,39.52766","116.71059,39.527689","116.711153,39.527738","116.711813,39.527784","116.712269,39.527821","116.712843,39.527858","116.713406,39.52791","116.713991,39.527939","116.714447,39.528017","116.715144,39.528071","116.715445,39.528104","116.715911,39.52817","116.716292,39.528212","116.716673,39.528257","116.717194,39.52834","116.717692,39.52839","116.717891,39.528406","116.718272,39.52846","116.718604,39.528497","116.718878,39.52853","116.719663,39.528619","116.720114,39.528648","116.720656,39.528701","116.720951,39.52871","116.721181,39.528735","116.721417,39.528743","116.722099,39.528797","116.722474,39.528792","116.722936,39.528855","116.723429,39.528871","116.723783,39.528892","116.724255,39.528925","116.724975,39.528979","116.725426,39.529008","116.726032,39.529049","116.726692,39.529107","116.727078,39.529165","116.72762,39.529214","116.727893,39.529247","116.728478,39.52926","116.729304,39.529318","116.730254,39.529388","116.73072,39.529425","116.731112,39.529463","116.731563,39.529487","116.732185,39.529545","116.732872,39.529591","116.733483,39.529653","116.733907,39.529678","116.734481,39.529715","116.734873,39.529752","116.734873,39.529752","116.735385,39.529765","116.736613,39.529844","116.737772,39.529902","116.738426,39.529935","116.738823,39.529955","116.739167,39.529976","116.739564,39.530013","116.740159,39.5301","116.740909,39.530197","116.741252,39.530239","116.741649,39.530313","116.742319,39.530404","116.742775,39.530466","116.743038,39.530495","116.743559,39.530582","116.744301,39.530681","116.744779,39.530759","116.745467,39.530845","116.745848,39.530903","116.746207,39.530965","116.746728,39.531027","116.74706,39.531077","116.747693,39.531159","116.748085,39.531217","116.748616,39.531292","116.749422,39.531407","116.75028,39.531531","116.751364,39.531618","116.752088,39.531684","116.752807,39.531754","116.755339,39.531982","116.756022,39.532033","116.756505,39.532096","116.757176,39.532129","116.757573,39.532162","116.75842,39.532236","116.758898,39.532265","116.760303,39.532381","116.760917,39.53244","116.761872,39.532531","116.762693,39.532593","116.763175,39.532617","116.763283,39.532634","116.764549,39.532725","116.764812,39.532758","116.766121,39.532874","116.76648,39.532882","116.767017,39.532946","116.767827,39.533016","116.768336,39.533086","116.768942,39.533107","116.769473,39.53319","116.769903,39.533235","116.770525,39.533306","116.772129,39.533467","116.77355,39.5336","116.774514,39.533703","116.77599,39.53384","116.777191,39.533981","116.778033,39.534055","116.778688,39.534109","116.779455,39.534204","116.779943,39.53427","116.780517,39.534307","116.781697,39.534423","116.781724,39.534705","116.781638,39.534978","116.781563,39.53528","116.781547,39.535313","116.781418,39.535846","116.781257,39.536368","116.781123,39.536893","116.78101,39.537332","116.78101,39.537332","116.780843,39.537994","116.780725,39.538416","116.780629,39.538829","116.780527,39.539094","116.78035,39.539748","116.780165,39.540429","116.779988,39.54102","116.779854,39.541508","116.779768,39.541885","116.779644,39.542294","116.77951,39.542766","116.779344,39.543382","116.779226,39.543821","116.779006,39.544607","116.778834,39.545194","116.778748,39.545533","116.778588,39.546162","116.778384,39.546882","116.778287,39.547304","116.778148,39.547726","116.777997,39.548305","116.777949,39.548533","116.777885,39.548783","116.777713,39.5494","116.777606,39.54976","116.777595,39.549751","116.777467,39.550239","116.777316,39.550806","116.777225,39.551191","116.777102,39.551571","116.777005,39.552001","116.776832,39.55259","116.776596,39.553434","116.776468,39.553914","116.776312,39.554431","116.77628,39.554588","116.776114,39.55513","116.775985,39.555638","116.775819,39.556304","116.775674,39.556829","116.775599,39.557152","116.775481,39.557661","116.775352,39.558074","116.775228,39.558525","116.775127,39.55893","116.775041,39.559199","116.774939,39.559617","116.77474,39.560279","116.774628,39.560725","116.774526,39.561077","116.774437,39.56142","116.774271,39.56197","116.77412,39.562532","116.774024,39.562909","116.773868,39.563355","116.773793,39.563752","116.773739,39.563947","116.773605,39.564397","116.773474,39.564889","116.773367,39.565298","116.773265,39.565642","116.773206,39.565861","116.773131,39.566146","116.773034,39.566473","116.772761,39.566485","116.772187,39.566374","116.771747,39.566316","116.771382,39.566254","116.770776,39.566134","116.770052,39.566039","116.76943,39.565915","116.769102,39.565882","116.768872,39.565811","116.768276,39.565762","116.76775,39.565675","116.767037,39.565526","116.766388,39.56541","116.765755,39.565298","116.765192,39.565228","116.764569,39.565121","116.763905,39.565011","116.763041,39.564854","116.762713,39.564894","116.761635,39.564704","116.761351,39.564658","116.761276,39.564911","116.761131,39.565494","116.76105,39.565775","116.760922,39.566209","116.760766,39.566842","116.760616,39.567346","116.760525,39.567681","116.760525,39.567681","116.760414,39.568107","116.760317,39.568426","116.760285,39.568599","116.760194,39.568897","116.760129,39.569207","116.76007,39.569422","116.760011,39.569649","116.759941,39.569881","116.759914,39.569984","116.759861,39.570216","116.759791,39.570423","116.759693,39.570812","116.759505,39.571498","116.759441,39.571788","116.759376,39.572007","116.759296,39.572284","116.759194,39.572689","116.759194,39.572689","116.758924,39.573637","116.75886,39.573943","116.759047,39.573976","116.759557,39.574046","116.759977,39.574124","116.760439,39.574194","116.760766,39.574256","116.761324,39.574343","116.761581,39.574413","116.762187,39.574521","116.762616,39.574566","116.762901,39.574607","116.76465,39.57488","116.765412,39.574996"]
    };

    var drivingRoute = "-";
    var gcnt = 0;
    /**
     * 连接服务器
     */
    function connect(){
        $.muyuSend.post("/nettyClient/initNettyClient",{"host": $("#host").val() , "port" : $("#port").val()},function (response) {
            if (response.code == 0){
                connectEnd();
            }else {
                $.modal.msgWarning(response.msg);
            }
        })
    }

    /**
     * 断开服务器
     */
    function disConnect(){
        $.muyuSend.get("/nettyClient/nettyDestroy",undefined,function (response) {
            if (response.code == 0){
                disconnect();
            }else {
                disconnect();
                $.modal.msgWarning(response.msg);
            }
        })
    }

    function connectEnd() {
        $("#connect").css("display","");
        $("#disconnect").css("display","none");
    }
    function disconnect() {
        $("#connect").css("display","none");
        $("#disconnect").css("display","");
    }

    $(function () {
        $.muyuSend.get("/nettyClient/status",undefined,function (response) {
            if (response.code == 0){
                connectEnd();
            }else {
                disconnect();
            }
        })
        // startNettyLog();
    })
    function addLog(msg){
        $("#vehicleMsgLog").append(msg);
    }

    function getSign(params, kAppKey, kAppSecret) {
        var content;
        if (typeof params == "string") {
            content = params
        } else if (typeof params == "object") {
            var arr = [];
            for (var i in params) {
                arr.push(i + params[i]);
            }
            arr = arr.sort()
            content = arr.join("")
        }
        var url = content + kAppSecret;
        console.log(url)
        return md5(url);
    }

    function startNettySendMsg(){
        var vin = $("#vin").val();
        gcnt = 0
        if (vin != null && vin != ''){
            // nettyMsgTime = setInterval("sendNettySendMsg()", 1000);
            $.muyuSend.get("/send_vehicle_start/"+$("#vin").val(),undefined,function (response) {
                if (response.code == 0){
                    uid = response.data.uid
                    nettyMsgTime = setInterval("sendNettySendMsg()", 1000);
                }else {
                    alert(response.msg);
                }
            })
        }else {
            $.modal.msgWarning("请输入VIN");
        }


    }
    function stopNettyStopMsg(){
        clearInterval(nettyMsgTime);
        gcnt = 0
        nettyMsgTime = null;    
        $.muyuSend.get("/send_vehicle_stop/"+$("#vin").val()+ "?uid=" + uid,undefined,function (response) {
          if (response.code == 0){
              $.modal.msgSuccess("车辆下线成功")
          }else {
              alert(response.msg);
          }
        })
    }
    function sendNettySendMsg(){
        var data = getFormToMap("vehicleForm");
        var loc = [];
        if (drivingRoute !== "-") {
            if (gcnt > path[drivingRoute].length - 1) {
                loc = path[drivingRoute][path[drivingRoute].length - 1].split(",")
            } else {
                loc = path[drivingRoute][gcnt].split(",");
            }
            data['latitude'] = loc[1]
            data['longitude'] = loc[0]
        }
        data['app_key'] = 'app1';
        data['timestamp'] = new Date().getTime();
        data['uid'] = uid
        var sign = getSign(data, 'app1', 'abcdef');
        data['sign'] = sign;
        console.log(data)

        $.muyuSend.post("/send_msg",data,function (response) {
            if (response.code != 0){
                $.modal.msgWarning(response.msg);
                stopNettyStopMsg();
            }
        })
        gcnt += 1;
    }

    function startNettyLog(){
        nettyLogTime = setInterval("getNettyLog()", 1000);
    }
    function stopNettyLog(){
        clearInterval(nettyLogTime);
        gcnt = 0
        nettyLogTime = null;
    }
    function getNettyLog(){
        $.muyuSend.get("/netty/log",undefined,function (response) {
            if (response.code == 0){
                addLog(response.msg);
            }else {
                $.modal.msgWarning(response.msg);
            }
        })
    }

    /**
     * 开始模拟数据
     */
    function startImitateData(){
        vehicleImitateData = setInterval("imitateData()", 1000);
    }
    /**
     * 结束模拟数据
     */
    function stopImitateData() {
        clearInterval(vehicleImitateData);
        vehicleImitateData = null;
    }

    function imitateData() {
        $("#vehicleForm input[type='text']").each(function () {
            var min = $(this).attr("min");
            var max = $(this).attr("max");
            var name = $(this).attr("name");
            var reserved = $(this).attr("reserved");
            if (min != null && min != '' && max != null && max != '' && reserved != null && reserved != ''){
                if (name === "mileage") {
                  var mileage = localStorage.getItem("mileage")
                  if (mileage == null) {
                      mileage = 5000
                  }
                  mileage = (parseFloat(random(min,max,reserved)) + parseFloat(mileage)).toFixed(reserved)
                  $(this).val(mileage);
                  localStorage.setItem('mileage', mileage)
                } else if (name == "speed") {
                  var speed = random(min,max,reserved);
                  if ((parseInt(random(0, 45)) == 2)) {
                      $(this).val(random(140, 180))
                  } else if ((parseInt(random(0, 45)) == 3)) {
                      $(this).val(random(0, 10))
                  } else {
                    $(this).val(speed);
                  }
                }
                else {
                  $(this).val(random(min,max,reserved));
                }
            }
        })
    }

    function random(min , max , reserved) {
        var randomNum = Math.random() * (max - min + 1) + parseInt(min);
        return (randomNum * 1).toFixed(reserved);
    }

    /**
     * 选择轨道
     */
    function selectLocus() {
        drivingRoute = $("#drivingRoute").val();
        if (drivingRoute != '-'){
            console.log(drivingRoute)
        }
    }


</script>
</html>
